#include"comm.hpp"

int main()
{
    // std::cout<< "client begin"<<std::endl;
    int wfd = open(NAMED_PID,O_WRONLY);//已只写的方式打开
    // std::cout<< "client end "<< std::endl;
    if(wfd <  0)//打开失败直接退出
    {
        exit(1);
    }

    //write

    char buffer[1024];
    while(true)
    {
        std::cout<< "plase Say #";
        fgets(buffer,sizeof(buffer),stdin);
        if(strlen(buffer)>0)
        {
            buffer[strlen(buffer)-1] = 0;//清除/n的影响
        }
        ssize_t w = write(wfd,buffer,strlen(buffer));
        assert( w == strlen(buffer));
        (void)w;
    }
    close(wfd);
    return 0;
}